

MINIMIZE = -1
MAXIMIZE = 2

class Score(object):
    def __init__(self, ind, name, label, type):
        self.ind = ind
        self.name = name
        self.label = label
        self.type = type
    
    def get_value(self):
        return getattr(self.ind, self.name)
    
    def is_minimize(self):
        return self.type == MINIMIZE
    
    def is_maximize(self):
        return self.type == MAXIMIZE
    
    def is_better(self, _score):
        assert self.name == _score.name
        assert self.type == _score.type
        
        if self.is_minimize():
            return self.get_value() < _score.get_value()
        else:
            return self.get_value() > _score.get_value()
            
    def is_equal(self, _score):
        assert self.name == _score.name
        assert self.type == _score.type
        return self.get_value() == _score.get_value()
    
    def __repr__(self):
        return str(self.get_value())